@mixin clearfix {
  &:after {
    content: "";
    display: table;
    clear: both;
  }
}

@mixin scrollBar {
  &::-webkit-scrollbar-track-piece {
    background: #d3dce6;
  }

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-thumb {
    background: #99a9bf;
    border-radius: 20px;
  }
}

@mixin relative {
  position: relative;
  width: 100%;
  height: 100%;
}

@mixin pct($pct) {
  width: #{$pct};
  position: relative;
  margin: 0 auto;
}

@mixin triangle($width, $height, $color, $direction) {
  $width: $width/2;
  $color-border-style: $height solid $color;
  $transparent-border-style: $width solid transparent;
  height: 0;
  width: 0;

  @if $direction==up {
    border-bottom: $color-border-style;
    border-left: $transparent-border-style;
    border-right: $transparent-border-style;
  }

  @else if $direction==right {
    border-left: $color-border-style;
    border-top: $transparent-border-style;
    border-bottom: $transparent-border-style;
  }

  @else if $direction==down {
    border-top: $color-border-style;
    border-left: $transparent-border-style;
    border-right: $transparent-border-style;
  }

  @else if $direction==left {
    border-right: $color-border-style;
    border-top: $transparent-border-style;
    border-bottom: $transparent-border-style;
  }
}

/**
* 溢出省略号
* @param {Number} 行数
*/
@mixin ellipsis($rowCount: 1) {
  @if $rowCount <=1 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  } @else {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: $rowCount;
    -webkit-box-orient: vertical;
  }
}

// $radius 填写的时候要比实际大2倍
@mixin border-1px($color:#ddd,$radius:0) {
  & {
    position: relative;
    border: none;
    &::before {
      content: '';
      position: absolute;
      left: 0;
      top: 0;
      width: 200%;
      height: 200%;
      border: 1px solid $color;
      transform-origin: 0 0;
      -webkit-transform: scale(0.5);
      transform: scale(0.5);
      box-sizing: border-box;
      z-index: 2;
      border-radius: $radius;
    }
  }
}

@mixin border-top-1px($color:#ebebeb,$clear:null) {
  & {
    position: relative;
    border: none;
    &::before {
      content: '';
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 1px;
      background-color: $color;
      transform-origin: 0 0;
      box-sizing: border-box;
      z-index: 2;
    }
    @if $clear == clear {
      &::after {
        display: none;
      }
    }
  }
  @media (-webkit-min-device-pixel-ratio: 1), (min-device-pixel-ratio: 1) {
    &::before {
      transform: scaleY(1);
    }
  }
  @media (-webkit-min-device-pixel-ratio: 2), (min-device-pixel-ratio: 2) {
    &::before {
      transform: scaleY(0.5);
    }
  }
  @media (-webkit-min-device-pixel-ratio: 3), (min-device-pixel-ratio: 3) {
    &::before {
      transform: scaleY(0.333);
    }
  }
}

@mixin border-bottom-1px($color:#ebebeb,$clear:null) {
  & {
    position: relative;
    border: none;
    &::after {
      content: '';
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      height: 1px;
      background-color: $color;
      transform-origin: 0 bottm;
      box-sizing: border-box;
      z-index: 2;
    }
    @if $clear == clear {
      &::after {
        display: none;
      }
    }
  }
  @media (-webkit-min-device-pixel-ratio: 1), (min-device-pixel-ratio: 1) {
    &::after {
      transform: scaleY(1);
    }
  }
  @media (-webkit-min-device-pixel-ratio: 2), (min-device-pixel-ratio: 2) {
    &::after {
      transform: scaleY(0.5);
    }
  }
  @media (-webkit-min-device-pixel-ratio: 3), (min-device-pixel-ratio: 3) {
    &::after {
      transform: scaleY(0.333);
    }
  }
}
